package com.syedu.day03.homework;

import java.util.Scanner;

/**
 * @Description
 * 写一个程序,计算饮料店第二杯半价
 * 要求输入购买饮料的单价和数量,然后计算一共需要花费多少钱?
 *
 * @createTime 2022/3/4 16:38
 * @author Administrator
 */
public class Exercise3 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请您输入单价和购买数量:");
        double price = scanner.nextDouble();
        int count = scanner.nextInt();
        /**注意: Java中两个相同数据类型进行运算,结果数据类型不变!!!*/
        double total = count / 2 * price + count / 2 * (price/2);
        //判断,如果购买的数量是奇数,则会少掉一杯全家,所以不上即可
        if(count % 2 != 0){
            total  = total + price;
        }
        System.out.println("您一共需要花费: " + total);
    }
}
